package com.zhi.util;

import com.zhi.entity.RunLog;
import com.zhi.service.RunLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Date;

/**
 * 日志表插入工具类
 * Component把普通实例化到spring容器中
 * Component泛指组件，当组件不好归类的时候，我们可以使用这个注解进行标注
 */
@Component
public class LogUtil {

    private static RunLogService runLogService;

    //自动实例化RunLogService
    @Autowired
    public void setRunLogService(RunLogService runLogService){
        LogUtil.runLogService = runLogService;
    }

    public static void insert(String businessNo,String businessType,String content){

        RunLog runLog = new RunLog();
        runLog.setBusinessNo(businessNo);
        runLog.setBusinessType(businessType);
        runLog.setContent(content);
        runLog.setOperator("sys");
        runLog.setOperateDate(new Date());
        runLogService.save(runLog);

    }

    public static void insert(String businessNo,String businessType,String content,String code1,String code2,String msg1,String msg2){

        RunLog runLog = new RunLog();
        runLog.setBusinessNo(businessNo);
        runLog.setBusinessType(businessType);
        runLog.setContent(content);
        runLog.setOperator("sys");
        runLog.setOperateDate(new Date());
        runLog.setCode1(code1);
        runLog.setCode2(code2);
        runLog.setMsg1(msg1);
        runLog.setMsg2(msg2);
        runLogService.save(runLog);

    }

}
